package com.zhibang.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: lewin
 * @date: 2024-12-27 16:43
 **/
@Configuration
@MapperScan("com.zhibang.mapper")
public class PlusConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 分页插件
        PaginationInnerInterceptor pii = new PaginationInnerInterceptor();
        pii.setOverflow(true); // 页码合理化
        pii.setDbType(DbType.MYSQL); // 数据库类型  (方言)
        interceptor.addInnerInterceptor(pii);
        return interceptor;
    }
}
